using System;
using System.Collections.Generic;
using System.Text;

namespace My.IdlConverter.Registration
{
    public enum KFreeDistribution
    {
        None,
        In,
        Out
    }

    public class FreeDistributionFactory
    {
        private static FreeDistributionFactory _instance;

        static FreeDistributionFactory()
        {
            _instance = new FreeDistributionFactory();
        }

        private FreeDistributionFactory()
        {
        }

        public static FreeDistributionFactory Instance
        {
            get{return _instance;}
        }

        public IFreeDistribution GetFreeDistribution(string from)
        {
            from = from.Trim();
            KFreeDistribution type = KFreeDistribution.None;
            if (from.Equals(Addin.FromIdlConverter))
                type = KFreeDistribution.In;
            else
                type =  KFreeDistribution.Out;

            return GetFreeDistribution(type);
        }

        public IFreeDistribution GetFreeDistribution(KFreeDistribution type)
        {
            switch(type)
            {
                case KFreeDistribution.In:
                    return new InFreeDistribution();
                case KFreeDistribution.Out:
                    return new OutFreeDistribution();
                default:
                    System.Diagnostics.Debug.Assert(false);
                    break;
            }

            return null;
        }
    }
}
